#include "PlaylistTab.h"

PlaylistTab::PlaylistTab(QWidget* parent) : QTableView(parent)
{
	tableModel=new TableModel();
	setModel(tableModel);
	horizontalHeader()->setResizeMode(QHeaderView::Stretch); 
}

void PlaylistTab::addEntry(Track* track)
{
	QModelIndex index;
	MusicList* list=tableModel->getList();
	qDebug() << list->size();
 	tableModel->insertRows(list->size(), 1, QModelIndex());
 	qDebug() << "Inserting row at position" << list->size();
 	list->add(track);
 	/*for(int i=0;i<tableModel->columnCount();i++)
 	{
 		switch(i)
 		{
 			case 0:
 			index=tableModel->index(list->size()-1, i, QModelIndex());
 			tableModel->setData(index, track->getTrackNumber(), Qt::EditRole);
 			break;
 			case 1:
 			index=tableModel->index(list->size()-1, i, QModelIndex());
 			tableModel->setData(index, track->getTitle(), Qt::EditRole);
 			break;
 			case 2:
 			index=tableModel->index(list->size()-1, i, QModelIndex());
 			tableModel->setData(index, track->getArtist(), Qt::EditRole);
 			break;
 			case 3:
 			index=tableModel->index(list->size()-1, i, QModelIndex());
 			tableModel->setData(index, track->getAlbum(), Qt::EditRole);
 			break;
 			case 4:
 			index=tableModel->index(list->size()-1, i, QModelIndex());
 			tableModel->setData(index, track->getTrackNumber(), Qt::EditRole);
 			break;
 			case 5: 
 			index=tableModel->index(list->size()-1, i, QModelIndex());
 			tableModel->setData(index, track->getLength(), Qt::EditRole);
 			break;
 			case 6:
 			index=tableModel->index(list->size()-1, i, QModelIndex());
 			tableModel->setData(index, track->getPath(), Qt::EditRole);
 			break;
 		}
	}*/
}
	
